package com.juttec.freshbird.pet.fragment;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.juttec.freshbird.pet.LuntanActivity;
import com.juttec.freshbird.pet.R;
import com.lidroid.xutils.ViewUtils;

/**
 * Created by Administrator on 2015/10/29.
 */
public class LeftFragment extends BaseFragment {

    private View view;
    private ListView mLvcechongwu;
    private ListView mLvcediqu;
    private ListView mLvcetopic;
    private ListView mLvceleft;
    private LinearLayout mlinearLayoutleft;
    private LinearLayout mlinearLayoutchongwu;
    private LinearLayout mlinearLayoutdiqu;
    private LinearLayout mlinearLayouttopic;

    @Override
    public View initViews() {
        view = View.inflate(mActivity, R.layout.left_fragment, null);
        mLvcechongwu = (ListView) view.findViewById(R.id.lv_ce_chongwu);
        mLvcediqu = (ListView) view.findViewById(R.id.lv_ce_diqu);
        mLvcetopic = (ListView) view.findViewById(R.id.lv_ce_topic);
        mLvceleft = (ListView) view.findViewById(R.id.lv_ce_left);
        mlinearLayoutleft = (LinearLayout) view.findViewById(R.id.ce_left);
        mlinearLayoutchongwu = (LinearLayout) view.findViewById(R.id.ce_chongwu);
        mlinearLayoutdiqu = (LinearLayout) view.findViewById(R.id.ce_diqu);
        mlinearLayouttopic = (LinearLayout) view.findViewById(R.id.ce_topic);
        ViewUtils.inject(view);
        return view;
    }
    @Override
    public void initData() {
    }
    //设置咨询界面的左边栏“选择类别listview”适配器
    public void setLeftAdapter(){
        //leftfragment布局里面有四个listview
        //设置“选择类别listview”模块可见，其余不可见
        mlinearLayoutleft.setVisibility(View.VISIBLE);
        mlinearLayoutchongwu.setVisibility(View.GONE);
        mlinearLayoutdiqu.setVisibility(View.GONE);
        mlinearLayouttopic.setVisibility(View.GONE);
        mLvceleft.setAdapter(new ListViewLeftAdapter());
        //资讯界面左边栏添加item点击事件监听
        mLvceleft.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(mActivity,"点击了", Toast.LENGTH_SHORT).show();
//                startActivity(new Intent(mActivity,));
            }
        });
    }
    //设置论坛界面的“宠物论坛lietview”适配器
    public void setChongwuAdapter(){
        //设置“宠物论坛listview”模块可见，其余不可见
        mlinearLayoutleft.setVisibility(View.GONE);
        mlinearLayoutchongwu.setVisibility(View.VISIBLE);
        mlinearLayoutdiqu.setVisibility(View.GONE);
        mlinearLayouttopic.setVisibility(View.GONE);
        mLvcechongwu.setAdapter(new ListViewChongwuAdapter());
        //论坛界面宠物右边栏添加item点击事件监听
        mLvcechongwu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                Toast.makeText(mActivity, "点击了主题", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(mActivity, LuntanActivity.class));
            }
        });
    }
    //设置论坛界面的“地区论坛listview”适配器
    public void setDiquAdapter(){
        //设置“地区论坛listview”模块可见，其余不可见
        mlinearLayoutleft.setVisibility(View.GONE);
        mlinearLayoutchongwu.setVisibility(View.GONE);
        mlinearLayoutdiqu.setVisibility(View.VISIBLE);
        mlinearLayouttopic.setVisibility(View.GONE);
        mLvcediqu.setAdapter(new ListViewDiquAdapter());
        //论坛界面地区右边栏添加item点击事件监听
        mLvcediqu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(mActivity, "点击了地区", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(mActivity, LuntanActivity.class));

            }
        });
    }
    //设置论坛界面的“主题论坛listview”适配器
    public void setTopicAdapter(){
        //设置“主题论坛listview”模块可见，其余不可见
        mlinearLayoutleft.setVisibility(View.GONE);
        mlinearLayoutchongwu.setVisibility(View.GONE);
        mlinearLayoutdiqu.setVisibility(View.GONE);
        mlinearLayouttopic.setVisibility(View.VISIBLE);
        mLvcetopic.setAdapter(new ListViewTopicAdapter());
        //论坛界面右边栏添加item点击事件监听
        mLvcetopic.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(mActivity, "点击了主题", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(mActivity, LuntanActivity.class));
            }
        });
    }
    //资讯界面左边栏适配器
    class ListViewLeftAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View inflate = View.inflate(mActivity, R.layout.listview_right_menu_item, null);
            TextView textView = (TextView) view.findViewById(R.id.tv_ce_left_title);
            textView.setText("选择类别");
            return inflate;
        }
    }
    //论坛界面右边栏宠物论坛适配器
    class ListViewChongwuAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View inflate = View.inflate(mActivity, R.layout.listview_right_menu_item1, null);
            TextView textView = (TextView) view.findViewById(R.id.tv_ce_chongwu_title);
            textView.setText("宠物论坛");
            return inflate;
        }
    }
    //论坛界面右边栏地区论坛适配器
    class ListViewDiquAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View inflate = View.inflate(mActivity, R.layout.listview_right_menu_item2, null);
            TextView textView = (TextView) view.findViewById(R.id.tv_ce_diqu_title);
            textView.setText("地区论坛");
            return inflate;
        }
    }
    //论坛界面右边栏主题论坛适配器
    class ListViewTopicAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View inflate = View.inflate(mActivity, R.layout.listview_right_menu_item3, null);
            TextView textView = (TextView) view.findViewById(R.id.tv_ce_topic_title);
            textView.setText("主题论坛");
            return inflate;
        }
    }
}
